package com.xnyzc.lhy.order.controller.dapi.service;

import com.xnyzc.lhy.common.exception.PangException;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.common.util.CheckUtil;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.order.service.score.IOaDServiceScoreService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Description
 * @Author Bin
 * @Date 2019/8/5 14:52
 **/
@RestController
@RequestMapping(value = "dapi/serviceScore")
public class ServiceScoreController {

    @Autowired
    private IOaDServiceScoreService iOaDServiceScoreService;

    @GetMapping(value = "getServiceScore")
    public Map<String, Object> getServiceScore(){
        Long driverId = TokenUtil.getTokenUserId();
        if (CheckUtil.objIsEmpty(driverId)){
            throw PangException.create(EErrorCode.tokenExpire);
        }
        String tag = TokenUtil.getTag();
        String userType = TokenUtil.getUserType();
        if (StringUtils.isEmpty(tag) || StringUtils.isEmpty(userType)){
            throw PangException.create(EErrorCode.missingAuthArgs);
        }
        return iOaDServiceScoreService.getComment(driverId, tag, userType);
    }
}
